const http = require('http');
const express = require('express');
const bodyParse = require('body-parser');
const cookieParse = require('cookie-parser');
const cors = require('cors');
const routerNews = require('./router/news');
const routerUser = require('./router/user');

let app = express();
http.createServer(app).listen(3000);

// 使用第三方中间件
app.use(bodyParse.urlencoded({extended: false}));
app.use(cookieParse());
app.use(cors({
    origin: ['http://localhost:63342', 'http://localhost:8081'],
    methods: ['PUT', 'DELETE', 'GET', 'POST']
}));

// 路由器
app.use('/news', routerNews);
// 在主模块中挂载路由器模块
app.use('/user', routerUser);
